/**
 * Copyright (2017, ) Institute of Software, Chinese Academy of Sciences
 * Copyright (2017, ) Bocloud Co,. Lmt
 */
package cn.abcsys.devops.core.excutors;

import java.util.Properties;

/**
 * @author wuheng@{otcaix.iscsa.ac.cn,beyondcent.com}
 * @date   May 21, 2017
 *
 * <code>Toolkit<code>是指CI工具集合，采用责任链设计模式，其默认顺序为
 * CODER,DOWNLOADER,ESTIMATOR,COMPILER,BUILDER,CHECKER,PUSHER
 */
public abstract class Toolkit {

	/**
	 * Gitlab源代码管理器
	 */
	public final static int CODER_GITLAB       = 11;
	
	/**
	 * SVN源代码管理器
	 */
	public final static int CODER_SVN          = 12;
	
	/**
	 * Github源代码管理器
	 */
	public final static int CODER_GITHUB       = 13;
	
	/**
	 * Gitlab源代码下载器
	 */
	public final static int DOWNLOADER_GITLAB  = 21;
	
	/**
	 * SVN源代码下载器
	 */
	public final static int DOWNLOADER_SVN     = 22;
	
	/**
	 * Github源代码下载器
	 */
	public final static int DOWNLOADER_GITHUB  = 23;
	
	/**
	 * Findbugs源代码分析器
	 */
	public final static int ESTIMATOR_FINDBUGS = 31;
	
	/**
	 * Sonar源代码分析器
	 */
	public final static int ESTIMATOR_SONAR    = 32;
	
	/**
	 * Maven源代码编译器
	 */
	public final static int COMPILER_MAVEN     = 41;
	
	/**
	 * Docker镜像生成器
	 */
	public final static int BUILDER_DOCKER     = 51;
	
	/**
	 * 物理环境镜像生成器
	 */
	public final static int BUILDER_PHSICAL    = 52;
	
	/**
	 * Clair镜像安全分析器
	 */
	public final static int CHECKER_CLAIR      = 61;
	
	/**
	 * Docker Registry镜像推送器
	 */
	public final static int PUSHER_REGISTRY    = 71;
	
	/**
	 * Habor镜像推送器
	 */
	public final static int PUSHER_HABOR       = 72;
	
	/**
	 * 物理镜像镜像推送器
	 */
	public final static int PUSHER_YUM         = 73;
	
	/**
	 * 工具集的用户名
	 */
	protected final String username;
	
	/**
	 * 工具集的密码
	 */
	protected final String password;
	
	protected int type;
	
	/**
	 * 工具集的其它属性
	 */
	protected final Properties props;

	public Toolkit(String username, String password, Properties props) {
		super();
		this.username = username;
		this.password = password;
		this.props = props;
	}

	public String getUsername() {
		return username;
	}

	public String getPassword() {
		return password;
	}

	public Properties getProps() {
		return props;
	}
	
	public abstract Object exec(String path, int type) throws Exception;

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}
	
	public abstract int getID();
	
}
